import grok

from zope.app.authentication import PluggableAuthentication
from zope.app.security.interfaces import IAuthentication

from biro.auth import setup_authentication

BIRO_VERSION = 0.2

class Biro(grok.Application, grok.Container):
    """The main biro class"""

    grok.local_utility(PluggableAuthentication, IAuthentication,
                       setup=setup_authentication)
    
    def __init__(self):
        super(Biro, self).__init__()
        
        self.birosettings = BiroSettings()
        self.biroversion = BIRO_VERSION
        
    #Common accessor
    def getblogtitle(self):
        return self.birosettings['blogtitle']
    
    def setblogtitle(self, title):
        del self.birosettings['blogtitle']
        self.birosettings['blogtitle'] = title
        
    blogtitle = property(getblogtitle, setblogtitle)

class BiroSettings(grok.Model, grok.Container):
    """ This is the class that holds all the biro settings"""
    
    def __init__(self):
        super(BiroSettings, self).__init__()
        
        self['blogtitle'] = "Blog Title"

class Index(grok.View):
    grok.context(Biro)